package com.xuxin.baby.view;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.AttributeSet;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatButton;

/**
 * Created by xu_xin
 * Created on 2020/12/2 0002
 */
public class SpecialButton extends AppCompatButton {

    public SpecialButton(@NonNull Context context) {
        super(context);
        init(context);
    }

    public SpecialButton(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public SpecialButton(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    /**
     * 设置字体
     */
    private void init(Context context) {
        AssetManager assets = context.getAssets();
        Typeface font = Typeface.createFromAsset(assets, "fonts/myfont.ttf");
        setTypeface(font);
        setLineSpacing(0, 1.1f);
    }
}